//开始写入，命名空间不会覆盖
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Google.Protobuf;
//结束写入，命名空间不会覆盖
namespace Player
{
	public class PlayerNet : Singleton<PlayerNet>
	{
		public override void Init()
		{
			base.Init();
			RegisterProtocol();
		}

		public void RegisterProtocol()
		{
			//开始自动生成注册protocol
			NetMgr.Instance.RegisterProtocol<PreLoginResponse>(2000111,PreLoginResponse_Res);
			NetMgr.Instance.RegisterProtocol<CreateResponse>(20002,CreateResponse_Res);
			NetMgr.Instance.RegisterProtocol<LoginResponse>(20003,LoginResponse_Res);
			NetMgr.Instance.RegisterProtocol<PlayerInfoResponse>(20005,PlayerInfoResponse_Res);
			//结束自动生成注册protocol
		}

		//开始自动生成PreLoginRequest请求
		/// <summary>
		/// PreLoginRequest请求
		/// </summary>
		/// <param name="openid">openId</param>
		async public void PreLoginRequest_Req(string openid)
		{
			PreLoginRequest req = new PreLoginRequest();
			req.OpenId = openid;
			//send protocol
			await NetMgr.Instance.SendProtocol(20001,req);
		}
		//结束自动生成PreLoginRequest请求
		//开始自动生成CreateRequest请求
		/// <summary>
		/// CreateRequest请求
		/// </summary>
		/// <param name="openid">openId</param>
		/// <param name="name">角色名称</param>
		async public void CreateRequest_Req(string openid,string name)
		{
			CreateRequest req = new CreateRequest();
			req.OpenId = openid;
			req.Name = name;
			//send protocol
			await NetMgr.Instance.SendProtocol(20002,req);
		}
		//结束自动生成CreateRequest请求
		//开始自动生成LoginRequest请求
		/// <summary>
		/// LoginRequest请求
		/// </summary>
		/// <param name="openid">openId</param>
		async public void LoginRequest_Req(string openid)
		{
			LoginRequest req = new LoginRequest();
			req.OpenId = openid;
			//send protocol
			await NetMgr.Instance.SendProtocol(20003,req);
		}
		//结束自动生成LoginRequest请求
		//开始自动生成LogoutRequest请求
		/// <summary>
		/// LogoutRequest请求
		/// </summary>
		async public void LogoutRequest_Req()
		{
			LogoutRequest req = new LogoutRequest();
			//send protocol
			await NetMgr.Instance.SendProtocol(20004,req);
		}
		//结束自动生成LogoutRequest请求
		//开始自动生成PlayerInfoRequest请求
		/// <summary>
		/// PlayerInfoRequest请求
		/// </summary>
		async public void PlayerInfoRequest_Req()
		{
			PlayerInfoRequest req = new PlayerInfoRequest();
			//send protocol
			await NetMgr.Instance.SendProtocol(20005,req);
		}
		//结束自动生成PlayerInfoRequest请求

		//以下是自动生成的响应，不会覆盖手写的代码
		//开始自动生成PreLoginResponse响应
		/// <summary>

		/// PreLoginResponse响应
		/// </summary>
		/// <param name="res">
		/// 
		/// </param>
		/// <value>
		/// res.Status	登录状态，0未创号，1正常登录，2封号禁止登录
		/// </value>
		public void PreLoginResponse_Res(PreLoginResponse res, int code)
		{
			if(code == 0)
			{
				//TODO
				
			}
		}
		//结束自动生成PreLoginResponse响应

		//开始自动生成CreateResponse响应
		/// <summary>

		/// CreateResponse响应
		/// </summary>
		/// <param name="res">
		/// 
		/// </param>
		/// <value>
		/// res.Status	创号状态，1创号成功，2重复创号
		/// </value>
		public void CreateResponse_Res(CreateResponse res, int code)
		{
			if(code == 0)
			{
				//TODO
				
			}
		}
		//结束自动生成CreateResponse响应

		//开始自动生成LoginResponse响应
		/// <summary>

		/// LoginResponse响应
		/// </summary>
		/// <param name="res">
		/// 
		/// </param>
		/// <value>
		/// res.PlayerId	玩家ID
		/// res.ServerTime	服务器时间
		/// </value>
		public void LoginResponse_Res(LoginResponse res, int code)
		{
			if(code == 0)
			{
				//TODO
				
			}
		}
		//结束自动生成LoginResponse响应

		//开始自动生成PlayerInfoResponse响应
		/// <summary>

		/// PlayerInfoResponse响应
		/// </summary>
		/// <param name="res">
		/// 
		/// </param>
		/// <value>
		/// res.PlayerId	玩家ID
		/// res.Name	玩家名称
		/// res.Gold	金币
		/// </value>
		public void PlayerInfoResponse_Res(PlayerInfoResponse res, int code)
		{
			if(code == 0)
			{
				//TODO
				
			}
		}
		//结束自动生成PlayerInfoResponse响应

	}
}
